var si = require('systeminformation');
var utils = require("./utils");

si.mem(function (data) {
    console.log(data);
});

setInterval(() => {
    console.log("==========");
    si.mem(function (data) {
        var memData = [{
            title: 'Memory', 
            // x: Array(61).fill().map((_, i) => 60 - i),
            // y: Array(61).fill(0)
        },
        {
            title: 'Swap', 
            // x: Array(61).fill().map((_, i) => 60 - i),
            // y: Array(61).fill(0)
        }
        ];
        var memPer = (100 * (1 - data.available / data.total)).toFixed();
        var swapPer = (100 * (1 - data.swapfree / data.swaptotal)).toFixed();

        swapPer = isNaN(swapPer) ? 0 : swapPer;

        // this.memData[0].y.shift();
        // this.memData[0].y.push(memPer);

        // this.memData[1].y.shift();
        // this.memData[1].y.push(swapPer);

        var memTitle =
            utils.humanFileSize(data.total - data.available) +
            ' of ' +
            utils.humanFileSize(data.total);

        var swapTitle =
            utils.humanFileSize(data.swaptotal - data.swapfree) +
            ' of ' +
            utils.humanFileSize(data.swaptotal);
 
        var memDonut=({
            percent: memPer,
            label: memTitle
        });
        var swapDonut=({
            percent: swapPer,
            label: swapTitle
        });
        console.log(memDonut,swapDonut)
    });
}, 1000);